<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
 <link href="${css}/bootstrap.min.css" rel="stylesheet"/>
 <link href="${css}/sb-admin-2.css" rel="stylesheet"/>
 <link href="${css}/patch.css" rel="stylesheet"/>
 <link rel="stylesheet" type="text/css" href="${plugins}/bootstrap-select/bootstrap-select.min.css"/>
<link rel="stylesheet" type="text/css" href="${plugins}/jquery-multi-select/css/multi-select.css"/>
        <div class="modal-dialog" >
            <div class="modal-content">
            
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button>
                    <h4 class="modal-title">分配用户</h4>
                </div>
                
                <div class="modal-body">
                <form class="form-horizontal" role="form" id="updateForm" name="role" action="" method="post">
					<div class="form-body">
		            <div class="form-group">
		            <input value="${roleId}"  id="roleId" type="hidden" />
						<label class="col-md-3 control-label">用户列表：</label>
						<div class="col-md-9">
							<select multiple="multiple" class="multi-select" id="my_multi_select1" name="my_multi_select1[]">
												<c:forEach items="${list1}" var="user1">
												<option value="${user1.id}">${user1.username}(${user1.mobile})</option>
												</c:forEach>
												<c:forEach items="${list2}" var="user2">
												<option value="${user2.id}" selected>${user2.username}(${user2.mobile})</option>
												</c:forEach>
											</select>
						</div>
					</div>
					</div>
					
				</form>
                </div>
                <div id="content"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="savePer" onclick="saveUserRoleAsso()" >保存</button>
                </div>
                
            </div>
        </div>
 <script src="${plugins}/bootstrap-select/bootstrap-select.min.js"></script>
 <script src="${plugins}/jquery-multi-select/js/jquery.multi-select.js"></script>     
<script type="text/javascript">
$(document).ready(function(){
	$('#my_multi_select1').multiSelect();
});

//保存用户分配信息
function saveUserRoleAsso(){
	var userIds = $("#my_multi_select1").val();
	var ids = new Array;
	if(userIds!=null&&userIds!=""){
	   ids=(userIds+"").split(",");
	}
	var roleId = $("#roleId").val();
	var url = "${ctx}/admin/mgmt/role/saveUserRoleAsso?userIds="+ids;
	$.ajax({
		type:"post",
		url:url,
		dataType:"json",
	    data:{
	    	'roleId':roleId
	    },
	    success:function(result){
	    	$("#dialog-Show").modal('hide');
	    },
	    error:function(data){
	    	
	    }
	});
}
</script>